package cn.tedu;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class Demo02 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入英雄名");
        String name = sc.nextLine();
        System.out.println("请输入英雄价格");
        int money = sc.nextInt();
        try (Connection conn = DBUtils.getConn();){
            String sql = "insert into hero values(null,?,?)";
            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setString(1,name);
            ps.setInt(2,money);
            ps.executeUpdate();
            System.out.println("添加完成!");
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
